import http from './http'

let UserCache = null

export const getUsers = async(index, pageSize) =>{
  UserCache = await http.fetchGet(`/api/user?pageSize=${pageSize}&pageIndex=${index}`);
  debugger;
return UserCache
}

export const getChannelWithEnable = async() =>{
  if(UserCache == null){
    UserCache = await http.fetchGet('/api/newschannel/all');
  }
  return UserCache.filter(c=> !c.disable).map(c=>{ return {...c} })
}

export const save = async(item) =>{
  UserCache = null
  await http.fetchPost(`/api/newschannel?name=${item.name}&status=${item.shortName}&priority=1`)
}
export const update = async(item) =>{
  UserCache = null
  await http.fetchPost('/api/newschannel/update', item)
}
